<?php
/**
 * Created by PhpStorm.
 * User: fengke
 * Date: 2018/12/10
 * Time: 16:25
 */

namespace app\common\model;


use think\Model;

class Collection extends Model
{
    // 表名
    protected $name = 'collection';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    /**
     * 函数用途描述:API获取列表展示
     * @author: Feng_Ke
     * @date: 2018/12/6 14:41
     * @param array $where
     * @param string $field
     * @return false|string|\think\Collection
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function getList($where=[],$order='',$limlt='',$field='*'){
        $list = $this
            ->where($where)
            ->order($order)
            ->limit($limlt)
            ->field($field)
            ->select();
        return $list;
    }

    /**
     * 函数用途描述: 获取采集网站详情
     * @author: Feng_Ke
     * @date: 2018/12/10 16:26
     */
    public function getCollectById($id,$field="*"){
        $result = $this->where('id',$id)
            ->where('status','<>',0)
            ->field($field)
            ->find();
        return $result;
    }
}